include('shared.lua')
ENT.RenderGroup = RENDERGROUP_OPAQUE

function ENT:Initialize()
	self.OwnedActors = {}
	self.AnimationQue = {}
	self.TransitionAnimation = "Walk"
end

function ENT:Think()

	self:NextThink(CurTime() + 250)
end

//****************************************************
//*	Draws the actor sequence waypoint
function ENT:Draw()
	
	if gDisplayJunk == true then
		//Draw the sequence node data
		if LocalPlayer():GetEyeTrace().Entity == self then
			self.BaseClass.DrawTrackNodeData(self)
			self.BaseClass.DrawHighlighted(self)
		end

		//Draw the floating number
		self.BaseClass.DrawNumber(self, self.NodeID)
		self.BaseClass.DrawStraightTrackSegment(self,self.BaseClass.Materials ["RoleplayPos"], 7)

		//Draw the node
		render.SetMaterial(self.BaseClass.Materials ["RoleplayNode"])
		render.DrawQuadEasy( self:GetPos(), Vector(0,0,1), 20, 20, Color(255,255,255,255))
	end
end

//****************************************************
//*	Enables the client to retrieve the parameters of 
//* this waypoint
function ENT:GetParameters()

	local parameters = {}
	parameters.TransitionAnimation = self.TransitionAnimation or "Walk"

	//TODO:
	//For some reason the get root node func won't work
	local rootWaypoint = GetRootNode(self)

	parameters.OwnedActors = rootWaypoint.OwnedActors or {}
	parameters.AnimationQue = self.AnimationQue or {}
	parameters.WaitTime = self:GetNWFloat(ACTSEQ_WAITTIME)

	return parameters
end

//****************************************************
//*	Enables the client to specify the animation data of
//* this waypoint
function ENT:SetParameters(parameters)

	
	local rootWaypoint = GetRootNode(self)	
	rootWaypoint.OwnedActors = parameters.OwnedActors
	
	self.AnimationQue = parameters.AnimationQue
	self.TransitionAnimation = parameters.TransitionAnimation or "Walk"

	local data = {}
	data.entityIndex = self:EntIndex()
	data.transitionAnimation	= self.TransitionAnimation
	data.animationSequence = self.AnimationQue
	data.ownedActors = {}

	for ak,ao in pairs(parameters.OwnedActors) do
		table.insert(data.ownedActors, ao:EntIndex())
	end
	data.playState = parameters.PlayState;
	datastream.Send("SetWaypointParameters", data);

end

